<!--#include file="pjson.asp"-->
<!DOCTYPE html>
<html>
<head>
  <title></title>
<%
  dim tn
  tn="log1"
  'sessionExpire
  easp.include "h.asp"
%>
  <style type="text/css">
  .layui-form-label {
	width: 80px;
	text-align: left;
  }
  #_title{
    color: #009688;
    font-family: Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 24px;
    padding-bottom: 15px;
  }
  .reply{display: none; position: absolute; right: 0; bottom: 12px;}
  li:hover .reply{display: block;}
  .look{display: none; position: absolute; right: 50px; bottom: 12px;}
  li:hover .look{display: block;}
  li:hover {background-color: #ebf4f5;}
  </style>
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-card"><br>
      <div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="test_form">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">检索</label>
            <div class="layui-input-block">
              <input type="text" lay-filter="log1_search" id="log1_search" name="<%=tn%>_search" class="layui-input" value="<%=val("log1_search")%>">
            </div>
          </div>
          <div class="layui-inline">
            <%
              echo myopt2_no_required("status","语言种类",sql2arr("select id,name1 from baseinfo where mode='工单状态'"),iif(val("status") = "",0,val("status")))
            %>
          </div>
          <div class="layui-inline">
              <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="<%=tn%>_search">
                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
          </button>
         <%
            btn0 tn&"_add2","新增题目" 
            btn0 "free","自由练习"
         %>
         </div>
        </div>
      </div>
      <div class="layui-card-body">
        <dl class="layuiadmin-card-status">
          <%
            hi "page",val("page")
            hi "status",val("status")
          %>
        </dl> 
        <div id="test1"></div>
	    </div>

    </div>
  </div>
  <script src="/<%=rootpath%>/src/layuiadmin/layui/layui.js"></script>  
  <script>
  layui.config({
    base: '/<%=rootpath%>/src/layuiadmin/'
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index','form','admin','laypage'], function(){
    var $ = layui.$
    ,admin=layui.admin
    ,laypage = layui.laypage
    ,form = layui.form;
    $('#log1_search').focus();
    var status=$("#status").val();
    let a={898:"onc_1.asp",899:"onjs_1.asp",2229:"oncpp_1.asp",900:"onasp_1.asp",1032:"onphp_1.asp"};
    form.on('submit(free)',function(data) {
      window.location.href = "/dzps/yx/"+a[status];
    });   
    form.on('select(status)', function(data){
        l_load();
        console.log(data.value); //得到被选中的值
    });    

    l_load();
    function l_load(){
      laypage.render({
        elem: 'test1' 
        ,count: <%=Easp.Db.PageRecordCount%> 
        ,limit: <%=Easp.Db.PageSize%>
        ,jump: function(obj, first){
          $.ajax({
                url:'pj2.asp?action=div_test&page='+obj.curr+"&log1_search="+$('#log1_search').val()+"&status="+$("#sel_status").val(),
                success:function(res){
                    status=$("#sel_status").val();
                    if(!first){layer.msg('第 '+ obj.curr +' 页');}
                    $('dl.layuiadmin-card-status').html(res);
                    $('#page').val(obj.curr);
                  },
                error:function(error){
                    alert('数据加载失败');
                }
            });
      }
      });
    }
  admin.events.look = function(othis){
    var $ = layui.$;
    var nid = othis.data('id');
    var url="/dzps/yx/"+a[status]+"?action=log1_get&log1_id="+nid;
    window.location.href =url;
    return;
  };  
  var status=$("#status").val();
  admin.events.log1_upd = function(othis){
    var $ = layui.$;
    var nid = othis.data('id');
    var index_=layer.open({
      type: 2
      ,skin: 'layui-layer-molv'
      ,title: '题目维护'
      ,content: 'log1_frm.asp?now=' + new Date().getTime()+"&id="+nid+"&status="+status
      ,maxmin: true
      ,btn: ['确定', '取消']
      ,yes: function(index, layero){
        var iframeWindow = window['layui-layer-iframe'+ index]
        ,submitID = 'LAY-user-front-submit'
        ,submit = layero.find('iframe').contents().find('#'+ submitID);
        iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
        var field = data.field; 
          $.post('pjson.asp?now=' + new Date().getTime(), {
            action: "log1_upd",field,status: status
          },
          function(data) {
            layer.msg($.parseJSON(data).msg);
          });
        layer.close(index); //关闭弹层
        });  
        submit.trigger('click');
        l_load();
      }
      ,success: function(layero, index){
      }
      });
      layer.full(index_);
  };
    form.on('submit(<%=tn%>_search)', function(data){
      l_load();
    });	
    form.on('submit(<%=tn%>_add2)', function(data){
     var index_=  layer.open({
        type: 2,skin: 'layui-layer-molv',title: '新增题目',content: '<%=tn%>_frm.asp?now=' + new Date().getTime() +"&status="+status,maxmin: true
        //,area: ['500px', '450px']
        ,btn: ['确定', '取消']
        ,yes: function(index, layero){
          var iframeWindow = window['layui-layer-iframe'+ index]
          ,submitID = 'LAY-user-front-submit'
          ,submit = layero.find('iframe').contents().find('#'+ submitID);
          iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
            var field = data.field; 

				$.post('pjson.asp?now=' + new Date().getTime(), {
					action: "<%=tn%>_add2",status:status,
					field
				},
				function(data) {
					layer.msg($.parseJSON(data).msg);
				});
            layer.close(index); 
          });  
          submit.trigger('click');
		      l_load();
        }
        ,success: function(layero, index){
        }
	  });	
	      layer.full(index_);
    });
  });
  </script>
</body>
</html>